//
// Created by nilyang on 2022/1/8.
//

#ifndef BASIC_CONCEPTS_H
#define BASIC_CONCEPTS_H

/// 是否整形
template<typename T> struct is_integer;
template<typename T> struct is_double;

/// 偏特化
template<>
struct is_integer<int>{
    typedef int type;
};

template<>
struct is_double<double> {
    typedef double type;
};


/// 概念约束
template<typename T>
concept IsInteger= requires(T) {
    typename is_integer<T>::type;
};

template<typename T>
concept IsDouble = requires(T) {
    typename is_double<T>::type;
};

/// 组合概念
template<typename T>
concept IsNumber = IsInteger<T> || IsDouble<T>;

/// 满足概念加法
template<IsInteger T>
T func_concepts_add(T a, T b);

/// 满足概念数字加法
template<IsNumber T>
T func_concepts_add(T a, T b);

/// 两种数字
template<IsNumber T, IsNumber U>
float func_concepts_add(T a,U b);

/// 概念测试函数
int func_concepts_test();

#endif //BASIC_CONCEPTS_H
